#define DEBUG
#include <cstdio>
#include <cmath>
#define MODS 100000007
#define MAXN 10000
#define MAXA 600
#define MAXP 109

using namespace std;

void makeMap(int n, int *map) {
  static bool book[MAXA+1];
  map[0]=0;
  for (int i=2; i<=n; i++) {
    if (!book[i]) {
      map[i] = ++map[0];
      for (int j=2; j*i<=n; j++) {
	book[i*j]=true;
      }
    }
  }
}

long long qpower(long long a, int n) {
  long long ret=a, s=1;
  for (; n>1; n/=2) {
    if (n%2) {
      s = s*ret%MODS;
    }
    ret = ret*ret%MODS;
  }
  return ret*s%MODS;
}

int main() {
#ifdef DEBUG
  freopen("4638.in", "r", stdin);
  freopen("4638.out", "w", stdout);
#endif

  static int map[MAXA+1];
  static long long phi[MAXN+1], primeof[MAXA+1][5];
  static bool book[MAXN+1][MAXP+1];
  for (int i=2; i<=MAXA; i++) {
    int x=i;
    for (int j=2; j<=sqrt(x); j++) {
      if (x%j==0) {
	primeof[i][++primeof[i][0]]=j;
      }
      for (; x%j==0; x/=j);
    }
    if (x>1) {
      primeof[i][++primeof[i][0]]=x;
    }
  }
  makeMap(MAXA, map);
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    int a;
    scanf("%d", &a);
    phi[i]=a;
    for (int j=1; j<=primeof[a][0]; j++) {
      phi[i] = phi[i]*(primeof[a][j]-1)%MODS*qpower(primeof[a][j], MODS-2)%MODS;
      book[i][map[primeof[a][j]]] = true;
    }
  }

  int q;
  scanf("%d", &q);
  for (int i=1; i<=q; i++) {
    int type;
    scanf("%d", &type);
    if (type) {
      int l, r;
      scanf("%d %d", &l, &r);
      long long ans=1;
      for (int j=l; j<=r; j++) {
	ans = ans*phi[j]%MODS;
      }
      printf("%lld\n", ans);
    } else {
      int l, r;
      long long x;
      scanf("%d %d %lld", &l, &r, &x);
      for (int j=l; j<=r; j++) {
	phi[j] = phi[j]*x%MODS;
	for (int k=1; k<=primeof[x][0]; k++) {
	  if (!book[j][map[primeof[x][k]]]) {
	    phi[j] = phi[j]*(primeof[x][k]-1)%MODS*qpower(primeof[x][k], MODS-2)%MODS;
	    book[j][map[primeof[x][k]]] = true;
	  }
	}
      }
    }
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
